package com.chapter2.basics;



import com.dennis.utils.Utils;

/**
 * 分治法
 * @author Administrator
 *
 */
public class Divide_Conquer_Approach {
	public static void main(String[] args){
		int[] A ,b,c ;
		A =Utils.getRandomArray(48, 100, 100);
		b = new int[A.length/2];
		c= new int[A.length/2];
		for(int i =0; i<A.length/2;i++){
			b[i] = A[i];
		}
		for(int i =0; i<A.length/2;i++){
			c[i] =A[i-1+A.length/2];
		}
		int i = 0 ,j = 0;
		for (int k= 0; k< A.length;k++) {
			if (b[i]<=c[j]) {
				A[k] = b[i];
				i++;
			}else {
				A[k] = c[j];
				j++;
			}
		}
		
		Utils.PrintArray(A);
	}
	
}
